/*
 * ========================================================
 * Copyright(c) 2014 杭州龙骞科技-版权所有
 * ========================================================
 * 本软件由杭州龙骞科技所有, 未经书面许可, 任何单位和个人不得以
 * 任何形式复制代码的部分或全部, 并以任何形式传播。
 * 公司网址
 * http://www.hzdracom.com/
 * ========================================================
 */
package com.shwread.httpsdk.http.face;

import java.util.HashMap;

import logic.constants.Const;

import org.json.JSONObject;

import android.content.Context;
import android.view.inputmethod.InputMethodManager;

import com.google.gson.reflect.TypeToken;
import com.shwread.httpsdk.http.base.AbstractHttpPostDracom;
import com.shwread.httpsdk.http.callback.ActionListener;
import com.shwread.httpsdk.util.MD5;


/**
 * @Project： Lqyd_Android
 * @Title：ModPasswordAction
 * @Description：用户修改密码
 * @Author：wayne
 * @Date：2014年8月15日上午11:22:48
 */
public class ModPasswordAction
        extends
        AbstractHttpPostDracom
{
	private String oldPassword;
	private String newPassword;
	
	/**
	 * <p>
	 * Title:
	 * </p>
	 * <p>
	 * Description:
	 * </p>
	 * 
	 * @param context
	 * @param action
	 * @param actionListener
	 */
	public ModPasswordAction(Context context, String oldPassword, String newPassword, ActionListener actionListener) {
		super(context, "modPassword.do", actionListener);
		this.oldPassword = oldPassword;
		this.newPassword = newPassword;
	}
	
	@Override
	public void getParameter(HashMap<String, String> parameter_map) {
		parameter_map.put("account", Const.phone_number);
		parameter_map.put("timeStamp", String.valueOf(timeStamp));
		parameter_map.put("oldPassword", MD5.MD5Encode(oldPassword));
		parameter_map.put("newPassword", MD5.MD5Encode(newPassword));
		parameter_map.put("cid", cid(Const.phone_number + Const.ACCOUNTTYPE + Const.CLIENTTYPE + timeStamp + MD5.MD5Encode(oldPassword) + MD5.MD5Encode(newPassword)));
	}
	
	@Override
	public void doResponseXml(String xml) {
		println(xml);
		int result = -1;
		try
		{
			JSONObject jsonObject = new JSONObject(xml);
			result = jsonObject.getInt("resultCode");
			if (result == 1000)
			{
				listener.OK(xml);
			}
			else
			{
				String message = gson.fromJson(jsonObject.getString("returnObject"), new TypeToken<String>(){
					
				}.getType());
				listener.ERROR(result, message);
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	@Override
	protected void doRequestHeader(HashMap<String, String> header_map) {
		
	}
	
	@Override
	public void dispose() {
		
	}
	
}
